// *** ADDED BY HEADER FIXUP ***
#include <string>
// *** END ***
#include "Clearance.h"

Clearance::Clearance(string level)
{
    setValor(level);
}

void Clearance::validar(string level)
{
    if(level=="A"||level=="U"){}
    else throw invalid_argument("Clearance Invalida");
}

Clearance::Clearance(Email mail)
{
    setValor_v2(mail);
}

void Clearance::setValor_v2(Email mail)
{
    string s;
    s = validarv2(mail);
    this->valor = s;
}

string Clearance::validarv2(Email mail)
{
    string s;
    EmailsAdmin admin;
    admin.setValidos();
    if(!admin.pesquisar(mail.getValor()))
    {
        s = "U";
    }
    else s = "A";
    return s;
}
